package com.foo.designpattern.proxy.dynamicproxy.jdkdynamicproxy;

import junit.framework.TestCase;

/**
 * com.foo.designpattern.proxy.proxy.dynamicproxy.jdkdynamicproxy
 * Created with IntelliJ IDEA.
 * User: wangyuxi
 * DateTime: 2016/4/1722:49
 *
 * @desc
 */
public class JDKProxyTestCase extends TestCase{

    public void testWangPoWithJiaShiJDKProxy() throws Throwable {
        // 实例化目标对象
        KindWoman userService =  new JiaShi();
        // 实例化InvocationHandler(表面在和王婆 啪啪啪~~~里面实际是贾氏)
        KindWoman proxy = new WangPo(userService).getProxy();
        // 调用代理对象的方法
        proxy.makeEyesWithMan();
        proxy.happyWithMan();

    }

    public void testWangPoWithPanJinLianJDKProxy() throws Throwable {
        // 实例化目标对象
        KindWoman userService =  new PanJinLian();
        // 实例化InvocationHandler(表面在和王婆 啪啪啪~~~里面实际是潘金莲)
        KindWoman proxy = new WangPo(userService).getProxy();
        // 调用代理对象的方法
        proxy.makeEyesWithMan();
        proxy.happyWithMan();

    }
}
